'use strict';let _ly=_wj(function*(b,a){let d=$(b).attr("sctnId",a).find("trigActList");"undefined"==typeof _My&&(yield _ty("file52.html"));_Fp(d);_Dt(d,yield _qf("trigActList"),a);_Nk(b);$("> header",b).on("click","[newAction]",()=>{_8g(b)}).on("click","[newSectn]",()=>{_Hw()}).on("click","[delSectn]",_Et(function*(){var c=$("trigAct",b);if(!c.length||(yield _Yo("","All actions in this section will be deleted. <hr b=3> Continue?"))){_pk(c);c=$("tabs > sectns");let e=$(`> [pnlId="${$(b).attr("pnlId")}"]`,
c),f=e.next()[0]||e.prev()[0]||e.parent().prev()[0];e.remove();b.remove();c.triggerEvt("change",!0);_Uj(f)()}})).on("mousedown","[select]",function(){_Na("trigActSelectMenu",this,{},{click(c){_no(b,$(this).attr("name"),c.ctrlKey);return!0}})}).on("mousedown","[selected]",function(){_Bk(this)})});
function _Fp(b){_Fh.setEvtLtnrs(b);_My.setEvtLtnrs(b);$(b).on("dblclick","actions1 > [delete]",function(){let a=$(this).closest("trigAct");a.next("sep").addBack().css("visibility","hidden").slideUp(_Ch(()=>_pk(a)))}).on("click","actions1 > [enable]",function(){_xa($(this).closest("trigAct"),"disabled")}).on("click","actions1 > [import]",function(){_ut($(this).closest("trigAct"))}).on("mousedown","actions1 > [menu]",function(){_Bk(this,{noSeps:""})}).on("change","trigAct > header [name=title]",function(a){$(this).closest("header").attr("hasTitle",
this.value?"":null)}).on("change","trigAct",_Et(function*(a){if(!$(a.target).parent().closest("[DataModule]")[0]){if(!$(this).attr("actionId")){var d=yield _qf("trigActList");let c=_yk(d);$(this).attr("actionId",c);let e=$(this).prevAll('trigAct:not([actionId=""]):first').attr("actionId");d.set(c,{sctnId:$(this.closest("panel")).attr("sctnId")},d.getPos(e)+1);_pd("trigActList",d)}$(this).removeAttr("empty");d=["trigActList",$(this).attr("actionId"),$(a.target).attr("name")];_pd(d,_pu(a.target))}})).on("mousedown",
function(a){1==a.which&&(a.target==this||a.target.parentElement==this?_Ct(this,a.clientX,a.clientY,!a.ctrlKey):"move"==getComputedStyle(a.target).cursor&&_Qt(this,a.target,a.clientX,a.clientY))})}function _Nk(b){const a=$("trigAct",b).length;return $("> header",b).attr("simple",6>a?"":null)}function _Dt(b,a,d){for(let [c,e]of a)e.sctnId==d&&b.append(_4g(c,e))}function _yk(b){for(var a=1;b.has(a);++a);return a}
var _zr=_wj(function*(){let b=yield _qf("trigActList");return function*(){for(let a=1;;++a)b.has(a)||(yield a)}});
function _4g(b="",a={}){return _Bj(_lo)`\n <trigAct actionId="${b}" class="${a.disabled?"disabled":""} ${a.collapsed?"collapsed":""}">\n <header ${a.title?"hasTitle":""}>\n ${_Lu("icon",a.icon)}\n <desc><input type=text name=title value="${_5h(a.title||"")}" autocomplete=off spellcheck=false placeholder="Enter a name for the action (optional)..."></desc>\n <actions1 popupCntr>\n ${_Do?"<button import>Import</button>":""}\n <!--button collapse></button-->\n <button enable></button>\n <button delete>Delete</button>\n <button menu>&vellip;</button>\n </actions1>\n </header>\n <content>\n ${_Fh.make(a.triggers,
"triggers")}\n ${_My.make(a.actions,"actions")}\n </content>\n </trigAct>\n <sep></sep>\n `}function _nt(b){$(b).closest("triggers, actions").triggerEvt("change",!0,!0)}
function _8g(b){b=$("> cont",b)[0].getBoundingClientRect();let a=document.elementFromPoint(b.left+100,b.top+5),d=$(a.closest("trigAct")).nextAll("sep:first")[0]||a.closest("sep");d||_6p("noClosestSep",{boundRect:b.sc(),elem:a.nodeName,coords:a.getBoundingClientRect().sc()});let c=$(d).nextAll("trigAct:first");c[0]&&c.is("[empty]")?(_Bd(()=>c.addClass("stickout")),setTimeout(()=>c.removeClass("stickout"),500)):_Dh(_4g().attr("empty",""),d,!0)}
let _Dh=_Et(function*(b,a,d=!1){if(d)var c=$(a)[0].getBoundingClientRect().bottom+150>window.innerHeight;b.insertAfter(a);d&&(b.addClass("insertFX"),yield e=>_Bd(e),c&&(b[1].scrollIntoView({behavior:"smooth",block:"nearest"}),yield _Pi(250)),b.removeClass("insertFX"));_Nk(a.closest("panel"))}),_yw=_Et(function*(b,a){let d=yield _qf("trigActList");var c=Object.keys(_hf._Ot);c=new RegExp(`"((?:${c.join("|")}):\\d+)"`,"g");var e=b.filter('[actionId]:not([actionId=""])').get()[a?"reverse":"slice"]();
for(let k of e){e=$(k).attr("actionId");let l=JSON.stringify(d[e]),m={};for(var f=void 0;f=c.exec(l);){f=f[1];let g=_Uk(f)[0],h=_er(f);_Pt(h)||h.name||(m[f]=yield _cy(g,h.value))}l=l.replace(c,(g,h)=>`"${m[h]||h}"`);f=_yk(d);d.set(f,JSON.parse(l),a?0:d.getPos(e)+1);a&&(d[f].sctnId=$(a).closest("panel").attr("sctnId"));_Dh(_4g(f,d[f]),a||$(k).next(),1==b.length)}_pd("trigActList",d)});
function _pk(b){let a=_Ch(()=>_1i()());b.filter('[actionId]:not([actionId=""])').each((d,c)=>{_pd(["trigActList",$(c).attr("actionId")],void 0,200,a)});b.next("sep").addBack().remove()}function _da(b){_ia(a=>{let d=b.get().map(c=>$(c).attr("actionId"));_gu(window.frameElement?window.parent:window)._3h([a,d],$("tabs tab[active]").attr("pnlId"))})}
function _3h(b,a=""){const d="string"==typeof b,c=$("<iframe>").prop("src",`${location.pathname}?file=${d?encodeURIComponent(b):"&storInit#"+a}`).prop("storInit",d?null:b).on("titleChange",function(){$("diagFrm > header > l",e).text(this.contentWindow.document.title)}).one("contentReady",(f,k)=>k?e.Show(!1):_5p(e))[0];b=Math.min(1030,$(window).width()-10);a=Math.min(650,$(window).height()-10);const e=_4f(" ",c,"settgsFileEdit",!0,[b,a]);$(e).captureTgtEvt("close",_Et(function*(f,k){k||(f.preventDefault(),
(yield _gu(c.contentWindow)._Do.safeToClose)&&_5p(this))})).find("diagFrm > header ctrls").prepend('\n <b popout title="Pop out"></b>\n <b maximize title="Maximize"></b>\n <b restore title="Restore"></b>\n ').on("click","[popout]",_Et(function*(){let f=c.contentWindow;if(yield _gu(f)._Do.safeToClose)window.open(f.location.href,"_blank"),_5p(e)})).on("click","[maximize], [restore]",()=>{$(e).toggleClass("maximized")})}
let _xa=_Et(function*(b,a,d=_up){if("collapsed"==a&&1==b.length&&(d==_up||b.hasClass(a)==!d)){let c=$("> content",b)[0],e=c.offsetHeight;e||(c.style.setProperty("height","auto","important"),e=c.offsetHeight,c.style.height="");c.style.cssText=`height: ${e}px ; transition: .3s height;`;yield f=>_Bd(f);setTimeout(()=>c.style.cssText="",300)}b.filter('[actionId]:not([actionId=""])').each((c,e)=>{c=d==_up?!$(e).hasClass(a):d;_pd(["trigActList",$(e).attr("actionId"),a],c?!0:void 0);$(e).toggleClass(a,c)})});
function _gr(b){_tl({trigActList:[]},a=>{let d=$(b).attr("sctnId");$("trigAct",b).each((c,e)=>{if(e=$(e).attr("actionId"))a.trigActList[e].sctnId=d,a.trigActList.setPos(e,c)});_Dd(a)})}var _Vd=_wj(function*(b,a){return"new"==b?yield d=>_Hw(a,d):yield _Uj($(`body > tabs tab[pnlId="${b}"]`)[0])});
function _Bk(b,a){let d=b.closest("panel");_Na("selectedTrigActMenu",b,{attrs:a},{click(c){let e=$(b.closest("trigAct")||$("trigAct.selected",d));switch($(this).attr("name")){case "delete":if("dblclick"!=c.type)return!1;_pk(e);_vp(d);break;case "enable":_xa(e,"disabled",_Bf);break;case "disable":_xa(e,"disabled",_be);break;case "tgglEnbl":_xa(e,"disabled");break;case "collapse":_xa(e,"collapsed",_be);break;case "unclpse":_xa(e,"collapsed",_Bf);break;case "duplcte":_yw(e);break;case "export":_da(e);
break;case "import":_ut(e);break;case "importTo":return{click(){_ut(e,$(this).attr("pnlId"));return!0},beforePopup:_wj(function*(f){f.append("<item pnlId><b>Main section</b></item>");for(let k of(yield _hf._jg())||[])f.append(`<item pnlId="${k.id}">${k.name}</item>`)})};case "dupToSectn":return{click(){_Vd($(this).attr("pnlId"))(f=>{_yw(e,$("trigActList > sep:first-of-type",f))});return!0},beforePopup:_wj(function*(f){for(let k of $("body > tabs tab[pnlId^=actions]:not([active])")){let l=_pu(k);f.append(`<item pnlId="${$(k).attr("pnlId")}">${l.name||
"<b>Main section</b>"}</item>`)}})}}return!0}})}
{var _no=function(a,d,c=!1){let e="trigAct"+({enbld:":not(.disabled)",dsbld:".disabled",colpsd:".collapsed",unclsd:":not(.collapsed)"}[d]||""),f="invert"==d;f||c||$("trigAct",a).removeClass("selected");c=$(e,a);"named"==d&&(c=c.filter((k,l)=>$("> header [name=title]",l).val()));c[f?"toggleClass":"addClass"]("selected");_vp(a)},_Qt=function(a,d,c,e){let f,k;$(window).on("mousemove.trigActMove",l=>{if(!f){f=$(d.closest("trigAct")).hasClass("selected")?$("trigAct.selected",a):$(d.closest("trigAct"));
for(var m of f)m.boundRect=m.getBoundingClientRect();m=f.first().next()[0].offsetHeight;for(var g of f)g.nextSep=g.nextElementSibling,$(g.nextSep).addClass("noExpand").css("height",m+g.boundRect.height),$(g).prev().add(g.nextSep).addClass("noTarget"),$(g).appendTo(document.body).addClass("floating").css({left:g.boundRect.left,top:g.boundRect.top,width:g.boundRect.width});$(document.body).addClass("trigActDrag")}for(var h of f)h.style.left=h.boundRect.left+l.clientX-c+"px",h.style.top=h.boundRect.top+
l.clientY-e+"px";let n;h=$(document.elementsFromPoint(l.clientX,l.clientY)).filter("sep");if(1<h.length){g=999999;for(let p of h)h=p.getBoundingClientRect(),h=Math.abs((h.top+h.bottom)/2-l.clientY),h<g&&(g=h,n=p)}else n=h[0];n!=k&&($(k).removeClass("hover"),k=n,$(k).addClass("hover"))}).on("mouseup.trigActMove",l=>{$(window).add("body > tabs").off(".trigActMove");if(f){let m=$(k).removeClass("hover").is("sep:not(.noTarget)");m&&$(k).after(f.get().map(g=>g.nextSep));for(let g of f)g.boundRect=g.nextSep.getBoundingClientRect();
for(let g of f)$(g).css("transform",`translate(${parseFloat(g.style.left)-g.boundRect.left}px, ${parseFloat(g.style.top)-g.boundRect.top}px)`),$(g.nextSep).css("height","").before(g);_Bd(()=>setTimeout(()=>{f.css("transform","");setTimeout(()=>{$(".noTarget, .noExpand").removeClass("noTarget noExpand");$(document.body).removeClass("trigActDrag");f.removeClass("floating")[0].style.cssText="";m&&(_Nk(_vp(a)),_Nk(_vp(k)),setTimeout(()=>_gr(k.closest("panel")),250))},280)},50))}});$("body > tabs").on("mouseenter.trigActMove",
"tab[pnlId^=actions]",function(){_Uj(this)()})},_Ct=function(a,d,c,e){const f=a.getBoundingClientRect(),k=d-f.left,l=c-f.top;let m;$(window).on("mousemove.selFrame",g=>{var h=a.getBoundingClientRect(),n=g.clientX-h.left,p=g.clientY-h.top;g=Math.min(k,n);h=Math.min(l,p);n=Math.max(k,n);p=Math.max(l,p);m||($(a).addClass("dragging"),m=$("<selectorFrame>").css({left:k,top:l}).appendTo(a));m.css({left:g,top:h,width:n-g,height:p-h});b(a)}).on("mouseup.selFrame",()=>{$(window).off(".selFrame");$("selectorFrame").remove();
$(a).removeClass("dragging")});e&&($("trigAct.selected",a).removeClass("selected"),_vp(a,!0));$("trigAct",a).each(function(){this.selected=$(this).hasClass("selected")})};let b=_Ow(100,a=>{let d=$("selectorFrame",a)[0];if(d){var c=d.getBoundingClientRect();$("trigAct",a).each(function(){let e=_Wt(c,this.getBoundingClientRect());$(this).toggleClass("selected",e!=this.selected)});_vp(a)}});var _vp=(a,d)=>{a=a.closest("panel");d=d?0:$("trigAct.selected",a).length;let c=$("header [selected]",a);$("num",
c).text(d);c.toggleClass("visible",0<d);return a}}function _8e(){for(var b=1;$(`tabs > sectns [value=${b}]`)[0];++b);return b}
function _Hw(b,a){let d=$(_3g({id:_8e(),name:b||"More Actions"})).appendTo("tabs > sectns").triggerEvt("change",!0);_Uj(d[0])(c=>{_Jh(`<c>${d.prev()[0]?"Drag to reorder":"Click to rename"}.</c>`,d,"rbt","infoBubble small","","opacity");setTimeout(()=>{if($("tip[move]",c).is(":visible"))$("tip[move] video",c).each((e,f)=>f.load()).show().animate({opacity:1},3E3,"",function(){this.play()}).on("ended",function(){setTimeout(()=>this.play(),1500)})},2500);a&&a(c)})}
function _3g(b){return`<tab pnlId="actions:${b.id}" value={}><param name=id value=${b.id} number><name name=name textInput spellcheck=false>${_5h(b.name||"")}</name></tab>`};
